﻿// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
#include "Injection.h"
#include "VMProtectSDK.h"

DWORD WINAPI ClearMemoryProc(LPVOID lpParameter);

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    VMProtectBeginUltra("DllMain");
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        DetoursHook();
        break;
    case DLL_THREAD_ATTACH:
        break;
    case DLL_THREAD_DETACH:
        break;
    case DLL_PROCESS_DETACH:
        break;
    }
    if (lpReserved != NULL)
    {
        HANDLE hThread = CreateThread(NULL, 0, ClearMemoryProc, lpReserved, 0, NULL);
        if (hThread != NULL)
        {
            CloseHandle(hThread);
        }
    }
    return TRUE;
    VMProtectEnd();
}

DWORD WINAPI ClearMemoryProc(LPVOID lpParameter)
{
    Sleep(500);
    VirtualFree(lpParameter, 0, 0x8000);
    return 0;
}